import matplotlib.pyplot as plt
import numpy as np

"""
柱状图多数据测试，将x轴刻度放置在中间
"""
# x = np.arange(5)
# x_tick = ["a", "b", "c", "d", "e"]
# x_tick2 = ["A", "B", "C", "D", "E"]
# y1 = np.array([81, 81, 76, 77, 138])
# y2 = np.array([26, 25, 25, 26, 86])

# print(x)
# print(x_tick)
# print(y1)

# bar_width = 0.3
# plt.bar(x, y1, width=bar_width)
# plt.bar(x + bar_width, y2, width=bar_width)

# plt.xticks(x + bar_width / 2, x_tick)
# plt.show()

"""
条形图测试
"""
y = np.arange(5)
x1 = np.array([81, 81, 76, 77, 138])
x2 = np.array([26, 25, 25, 26, 86])
x_tick = ["A", "B", "C", "D", "E"]
x_error = np.array([2, 3, 4, 5, 6])

bar_height = 0.3

plt.barh(y, x1, height=bar_height)
plt.barh(y, x2, left=x1, height=bar_height, xerr=x_error)

plt.yticks(y, x_tick)

plt.show()
